package com.test.sdk.common.util;

import lombok.Data;

/**
 * 所有接口统一封装到这个实体类中
 *
 * @author 徒有琴
 */
@Data
public class ResponseTO {
    private boolean success;
    private ErrorCodeTO error;
    private Object result;
    private String ticket;

    public static ResponseTO getOkResult(Object result) {
        ResponseTO res = new ResponseTO();
        res.setSuccess(true);
        res.setResult(result);
        return res;
    }

    public static ResponseTO getOkResult(Object result, String ticket) {
        ResponseTO res = new ResponseTO();
        res.setSuccess(true);
        res.setResult(result);
        res.setTicket(ticket);
        return res;
    }

    public static ResponseTO getErrorResult(ErrorCodeTO code) {
        ResponseTO res = new ResponseTO();
        res.setError(code);
        return res;
    }
}
